import classUtils.User;
import org.springframework.beans.BeanUtils;

import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;

/**
 * @program: pangu
 * @description:
 * @author: fengjd
 * @create: 2022-06-23 09:13
 **/
public class BeanUtilsTest {

    public static void main(String[] args) {

        /* 1.拷贝对象属性*/
        User user1 = new User();
        User user2 = new User();
        BeanUtils.copyProperties(user1,user2);

        /* 2. 实例化某个类*/
        User user = BeanUtils.instantiateClass(User.class);
        System.out.println(user);

        /*3.获取指定类的指定方法*/
        Method getId = BeanUtils.findDeclaredMethod(User.class, "getId");
        System.out.println(getId);

        /*4.获取指定方法的参数*/
        Method getId1 = BeanUtils.findDeclaredMethod(User.class, "getId");
        PropertyDescriptor propertyForMethod = BeanUtils.findPropertyForMethod(getId1);
        System.out.println("propertyForMethod.getName() = " + propertyForMethod.getName());

        /**/

    }
}
